package com.sh.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sh.dao.RroomDao;
import com.sh.entity.Rroom;
import com.sh.util.Result;

@RestController
public class RroomController {
	@Autowired
	private RroomDao rroomDao;

	@RequestMapping("/selectRroom")
	public Result getAll(Integer limit, Integer page, Rroom rroom, Map<String, Object> map) {
		map.put("page", (page - 1) * limit);
		map.put("limit", limit);
		map.put("rclass", rroom.getRclass());
		List<Map<String, Object>> getAlList = rroomDao.getAll(map);
		Integer getInteger = rroomDao.getCount();
		Result result = new Result(true, 0, null, getInteger, getAlList);
		return result;
	}

	// 添加
	@RequestMapping("/insertRroom")
	public Result insertComputers(Rroom rroom) {
		int inserts = rroomDao.insertRroom(rroom);
		Result res = new Result(200, "", inserts, true);
		return res;
	}

	// 修改
	@RequestMapping("/updateRroom")
	public Result updateComputers(Rroom rroom) {
		int updates = rroomDao.insertRroom(rroom);
		Result res = new Result(200, "", updates, true);
		return res;
	}

	// 删除
	@RequestMapping("/deleteRroom")
	public Result deleteComputers(Integer rRnum) {
		int i = rroomDao.deleteRroom(rRnum);
		Result res = new Result(200, "", i, true);
		return res;

	}

}
